package com.storm.lib;

/**
 * @author bigbird-0101
 * @date 2023-08-17 17:14
 */
public class OPCDaManager {

    static{
        System.load("D:\\ideaWorkSpace3\\study-project\\jni\\src\\main\\resources\\OPCDALib.dll");
    }

    public static void onChangeCallback(long arg1, String arg2, Object arg3, long arg4, int arg5) {
        System.out.println("callback");
        // 方法体
        System.out.println(arg1+arg2+arg3+arg4+arg5);
    }

    public native long create();
    public native void destroy(long client);
    public native void connect(long client,String host,String progId);
    public native void disconnect(long client);
    public native int addTag(long client,String tagName);
    public native long removeTag(long client,int tagHandle);
    public native Object[] getOpcServers(long client,String host);
    public native Object[] getOpcServerTags(long client);
    public native Object[] getOpcServerTagBranches(long client,String input);
    public native Object[] getOpcServerTagLeafs(long client,String input);
    public native Object readTag(long client,int tagHandle);
    public native void writeTag(long client,int tagHandle,Object obj,String type);

    public static void main(String[] args) {
        OPCDaManager opcDaManager=new OPCDaManager();
        long l = opcDaManager.create();
        System.out.println(l);
        opcDaManager.connect(l,"10.82.13.74","Kepware.KEPServerEX.V6");
        Object[] opcServerTags = opcDaManager.getOpcServerTags(l);
        System.out.println(opcServerTags);
        int adddd = opcDaManager.addTag(l, "adddd");
        System.out.println(adddd);
        opcDaManager.writeTag(l,adddd,"123","1");
        Object o = opcDaManager.readTag(l, adddd);
        System.out.println(o);
        opcDaManager.disconnect(l);
    }
}
